package cn.sitedev.lazy;

/**
 * @author qchen
 * @description 懒汉式单例
 * 优点: 节省了内存, 线程安全
 * 缺点: 性能较低
 * @date 2020/9/17 1:44
 */
public class Singleton2Sync {
    private static Singleton2Sync instance;

    private Singleton2Sync() {

    }

    public static synchronized Singleton2Sync getInstance() {
        if (instance == null) {
            instance = new Singleton2Sync();
        }
        return instance;
    }
}
